import request from '@/config/axios'

export interface AssignUserRoleVO {
  userId: string
  roleIds: number[]
}

export interface AssignRoleMenuVO {
  roleId: number
  menuIds: number[]
}

export interface AssignRoleDataScopeVO {
  roleId: number
  dataScope: number
  dataScopeDeptIds: number[]
}

export const getUserRoleIds = async (userId: string) => {
  return await request.get({ url: '/system/permission/list-user-roles', params: { userId } })
}

export const assignUserRole = async (data: AssignUserRoleVO) => {
  return await request.post({ url: '/system/permission/assign-user-role', data })
}

export const getRoleMenuIds = async (roleId: number) => {
  return await request.get({ url: '/system/permission/list-role-menus', params: { roleId } })
}

export const assignRoleMenu = async (data: AssignRoleMenuVO) => {
  return await request.post({ url: '/system/permission/assign-role-menu', data })
}

export const assignRoleDataScope = async (data: AssignRoleDataScopeVO) => {
  return await request.post({ url: '/system/permission/assign-role-data-scope', data })
}
